using Colorful.CMS;
using Colorful.Database;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Colorful.Models
{
    #region 产品类别标签
    public class ProductSortTags : IDataSource
    {
        private List<JsonData<string>> _datas;
        public List<JsonData<string>> Datas
        {
            get
            {
                if (_datas == null)
                {
                    using (var db = DbHelper.GetDb())
                    {
                        _datas = db.Tags.Where(a => a.Sort == (int)TagType.ProductSort).Select(a => a.Name).ToList().Select(a => new JsonData<string>() { id = a, text = a }).ToList();
                    }
                }
                return _datas;
            }
        }
    }
    #endregion
}
